#include "tool_commands.h"

#include <QDebug>
#include <QGraphicsScene>

#include "../page.h"

AddGraphicItemCommand::AddGraphicItemCommand(Page *page, QGraphicsItem *item): QUndoCommand(0)
{
    this->page = page;
    this->item = item;
}

void AddGraphicItemCommand::redo()
{
    item->setParentItem(page);
}

void AddGraphicItemCommand::undo()
{
    page->scene()->removeItem(item);
}

EraserUndoCommand::EraserUndoCommand(QGraphicsItem* item): QUndoCommand(0)
{
    m_item = item;
    m_parent = item->parentItem();
}

void EraserUndoCommand::redo()
{
    m_item->scene()->removeItem(m_item);
}

void EraserUndoCommand::undo()
{
    m_item->setParentItem(m_parent);
}
